﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace SqlMiM.Common.Model
{
    public class Server 
    {

        public bool IsCaseSensitive { get; set; }
        public bool IsFullTextInstalled { get; set; }
        public byte MaxPrecision { get; set; }
        public string VersionString { get; set; }
        public string ServerName { get; set; }
        public string Edition { get; set; }
        public string ProductLevel { get; set; }
        public bool IsClustered { get; set; }
        public bool IsSingleUser { get; set; }
        public Int32 EngineEdition { get; set; }
        public string ResourceVersionString { get; set; }
        public DateTime ResourceLastUpdateDateTime { get; set; }
        public DateTime LoginUpTime { get; set; }

        public string BuildClrVersionString { get; set; }
        public string Collation { get; set; }
        public string NetName { get; set; }


        //public ObservableCollection<InputOutputView> inputsOutuputsView;

        //public ObservableCollection<InputOutputView> InputsOutuputsView
        //{
        //    get { return inputsOutuputsView; }
        //    set { inputsOutuputsView = value; this.RaisePropertyChanged("InputsOutuputsView"); }
        //}



        public Server()
        {
            
        }


        public static void FillFromReader(SqlDataReader reader, Server server)
        {
            server.BuildClrVersionString = reader["BuildClrVersionString"] as String;
            server.ServerName = reader["ServerName"] as String;
            server.Collation = reader["Collation"] as String;
            server.Edition = reader["Edition"] as String;
            server.EngineEdition = reader["EngineEdition"] != System.DBNull.Value ? (Int32)reader["EngineEdition"] : 0;
            server.IsCaseSensitive = reader["IsCaseSensitive"] != System.DBNull.Value ? (Boolean)reader["IsCaseSensitive"] : false;
            server.IsClustered = reader["IsClustered"] != System.DBNull.Value ? (Boolean)reader["IsClustered"] : false;
            server.IsFullTextInstalled = reader["IsFullTextInstalled"] != System.DBNull.Value ? (Boolean)reader["IsFullTextInstalled"] : false;
            server.IsSingleUser = reader["IsSingleUser"] != System.DBNull.Value ? (Boolean)reader["IsSingleUser"] : false;
            server.MaxPrecision = reader["MaxPrecision"] != System.DBNull.Value ? (Byte)reader["MaxPrecision"] : (Byte)0;
            server.NetName = reader["NetName"] as String;
            server.ProductLevel = reader["ProductLevel"] as String;
            server.ResourceLastUpdateDateTime = reader["ResourceLastUpdateDateTime"] != System.DBNull.Value ? (DateTime)reader["ResourceLastUpdateDateTime"] : DateTime.Now;
            server.ResourceVersionString = reader["ResourceVersionString"] as String;
            server.VersionString = reader["VersionString"] as String;
        }
    }

}
